package com.cjm.one.controller.goods;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjm.one.common.result.Result;
import com.cjm.one.model.goods.entity.GoodsSku;
import com.cjm.one.model.goods.enums.SortStrategyEnum;
import com.cjm.one.service.GoodsSkuService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@Tag(name = "商品分类", description = "商品分类管理")
@RequestMapping("/api/goods/sku")
public class GoodsSkuController {
    @Resource
    private GoodsSkuService goodsSkuService;
    @GetMapping("/list")
    @Operation(summary = "分页查询商品sku")
    public Result<Page<GoodsSku>> pageList(@RequestParam(name = "current",defaultValue = "1") Long current,
                                           @RequestParam(name = "size",defaultValue = "10") Long size,
                                           @RequestParam(name = "categoryId", required = false) Long categoryId,
                                           @RequestParam(name = "name", required = false) String name,
                                           @RequestParam(name = "SortStrategy", required = false) SortStrategyEnum strategyEnum){
            return goodsSkuService.pageList(current,size,categoryId,name,strategyEnum);
    }
    @GetMapping("/ByCategoryId/list")
    @Operation(summary = "根据分类查询sku")
    public Result<Page<GoodsSku>> pageListByCategoryId(@RequestParam(name = "categoryId", required = true) Long categoryId,
                                                       @RequestParam(name = "current",defaultValue = "1") Long current,
                                                       @RequestParam(name = "size",defaultValue = "10") Long size){
        return goodsSkuService.pageListByCategoryId(categoryId,current,size);
    }

    @GetMapping("/coupon/list")
    @Operation(summary = "获取限定优惠商品")
    public Result<Page<GoodsSku>> getSkuCoupon(@RequestParam("ids") Long[] ids){
        return goodsSkuService.pageListByCoupon(ids);

    }
}
